<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>
    <script>
        var obj1={
            name:"阿尔菲娜额",
            age:32,
            list:[{a:324,b:1243}],
            children:{
                name:"萨丁",
                age:1423
            },
            show(){}
        }

        function copyObj(o){
            var newObj=Array.isArray(o)?[]:{};
            for(var key in o){
                if(typeof(o[key])==="object"){
                    newObj[key]=copyObj(o[key])
                }else{
                    newObj[key]=o[key];
                }
            }
            return newObj;
        }

        var obj2=copyObj(obj1);
        obj1.list[0].a=4352;
        console.log(obj1);
        console.log(obj2);
    </script>
</body>
</html>